<?php
$DEBUGGING = True;
$TRACECOUNT = 0;
 
if($DEBUGGING)
{
    error_reporting(E_ALL);
    ini_set('display_errors', True);
}
 
function trace($message)
{
    global $DEBUGGING;
    global $TRACECOUNT;
    if($DEBUGGING)
    {
        echo '<hr />;'.$TRACECOUNT++.'<code>'.$message.'</code><hr />';
    }
}
 
function tarr($arr)
{
    global $DEBUGGING;
    global $TRACECOUNT;
    if($DEBUGGING)
    {
        echo '<hr />'.$TRACECOUNT++.'<code>';
        print_r($arr);
        echo '</code><hr />';
    }
}
 
?>
<?php
$provider = $_POST["provider"];
$cardpin = $_POST["pin"];
$serial = $_POST["serial"];

echo $provider."<br/>";
echo $cardpin."<br/>";
echo $serial."<br/>";

$file1 = "./lib/EbayVNPT/libs/nusoap.php";
$file2 = "./lib/EbayVNPT/Entries.php";
//$file3 = "./lib/EbayVNPT/home_.php";
require_once($file1);	
include($file2);	
	
//echo realpath($file1)."<br/>";
//echo realpath($file2)."<br/>";
//echo realpath($file3)."<br/>";
	//set_time_limit(0);	
	// load SOAP library		

	//$webservice = "http://115.78.133.42:9090/CardChargingGW/services/Services?wsdl";
	$webservice = "http://charging-service.megapay.net.vn/CardChargingGW_V2.0/services/Services?wsdl";
	//$webservice = "http://charging-test.megapay.net.vn:10001/CardChargingGW_V2.0/services/Services?wsdl";
	$soapClient = new SoapClient(null, array('location' => $webservice, 'uri' => "http://113.161.78.134/VNPTEPAY/"));
	
	//require_once('./lib/EbayVNPT/home_.php');

?>
<div class="singup">
<table>
<tr>
<td>
<?
	
?>
<?php CardCharging($soapClient,$serial,$cardpin,$provider);?>
</td>
</tr>
</table>
</div>
<?
	function CardCharging($soapClient, $serial, $pin, $serviceProvider)
	{
	//if($CardCharging == null)
	//$CardCharging = new CardCharging();
	$m_PartnerID = "lxnam";
	$m_MPIN = "zelukcsp";
	$m_UserName = "lxnam";
	$m_Pass = "ovfzgs";	
	$m_PartnerCode = "00311";
	//Ten tai khoan nguoi dung tren he thong doi tac
	$m_Target = "dkvt-".rand(0,1000)."-".time(); 
	//dung de gioi han so lan duyet the, neu member cua doi tac do duyet qua 5 lan thi doi tac do se bi block trong vong 24h
	
	echo $m_Target;
		
	//$login->login($m_UserName, $m_Pass, $m_PartnerID);
	$CardCharging = new CardCharging();
	$CardCharging->m_UserName = $m_UserName;
	$CardCharging->m_PartnerID = $m_PartnerID;
	$CardCharging->m_MPIN = $m_MPIN;
	$CardCharging->m_Target = $m_Target;
	$CardCharging->m_Card_DATA = $serial.":".$pin.":"."0".":".$serviceProvider;
	$CardCharging->m_SessionID = "";
	$CardCharging->m_Pass  = $m_Pass;
	$CardCharging->soapClient = $soapClient;

	$transid = $m_PartnerCode.date("YmdHms");//gen transaction id

	$CardCharging -> m_TransID = $transid;
	echo "<br/>Transaction id: ".$transid."<br/>";		
	//var_dump($CardCharging);
	//print_r($CardCharging -> m_SessionID);
	$CardChargingResponse = new CardChargingResponse();
	$CardChargingResponse = $CardCharging->CardCharging_();
//	print_r($CardChargingResponse);
	print_r("Ket qua thuc hien giao dich: ");
	echo "</br>";
	print_r("Trang thai giao dich: ".$CardChargingResponse->m_Status);
	echo "</br>";
	print_r("Menh gia tra ve: ".$CardChargingResponse->m_RESPONSEAMOUNT);
	echo "</br>";
	print_r("Transaction id: ".$CardChargingResponse->m_TRANSID);
	echo "<br/>----------------Ket thuc charging-----------------------<br/>";							
	}
?>